package io.geekidea.boot.config;

import com.hwtx.form.domain.DbMessageSource;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.context.support.ResourceBundleMessageSource;

@Configuration
public class MessageSourceConfig {

    public static final String I18N_MESSAGE_SOURCE = "iMessageSource";
    @Bean
    @Primary
    public MessageSource messageSource() {
        return new DbMessageSource();
    }

    @Bean(I18N_MESSAGE_SOURCE)
    public ResourceBundleMessageSource iMessageSource() {
        ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
        messageSource.setBasename("messages");
        messageSource.setDefaultEncoding("UTF-8");
        return messageSource;
    }
}